package com.ruoyi.football.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.football.domain.StadiumDetail;
import com.ruoyi.football.service.IStadiumDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 球场场地详情Controller
 * 
 * @author ruoyi
 * @date 2024-12-10
 */
@RestController
@RequestMapping("/football/stadiumDetail")
public class StadiumDetailController extends BaseController
{
    @Autowired
    private IStadiumDetailService stadiumDetailService;

    /**
     * 查询球场场地详情列表
     */
//    @PreAuthorize("@ss.hasPermi('football:stadiumDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(StadiumDetail stadiumDetail)
    {
        startPage();
        List<StadiumDetail> list = stadiumDetailService.selectStadiumDetailList(stadiumDetail);
        return getDataTable(list);
    }

    /**
     * 导出球场场地详情列表
     */
//    @PreAuthorize("@ss.hasPermi('football:stadiumDetail:export')")
    @Log(title = "球场场地详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StadiumDetail stadiumDetail)
    {
        List<StadiumDetail> list = stadiumDetailService.selectStadiumDetailList(stadiumDetail);
        ExcelUtil<StadiumDetail> util = new ExcelUtil<StadiumDetail>(StadiumDetail.class);
        util.exportExcel(response, list, "球场场地详情数据");
    }

    /**
     * 获取球场场地详情详细信息
     */
//    @PreAuthorize("@ss.hasPermi('football:stadiumDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stadiumDetailService.selectStadiumDetailById(id));
    }

    /**
     * 新增球场场地详情
     */
//    @PreAuthorize("@ss.hasPermi('football:stadiumDetail:add')")
    @Log(title = "球场场地详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StadiumDetail stadiumDetail)
    {
        return toAjax(stadiumDetailService.insertStadiumDetail(stadiumDetail));
    }

    /**
     * 修改球场场地详情
     */
//    @PreAuthorize("@ss.hasPermi('football:stadiumDetail:edit')")
    @Log(title = "球场场地详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StadiumDetail stadiumDetail)
    {
        return toAjax(stadiumDetailService.updateStadiumDetail(stadiumDetail));
    }

    /**
     * 删除球场场地详情
     */
//    @PreAuthorize("@ss.hasPermi('football:stadiumDetail:remove')")
    @Log(title = "球场场地详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stadiumDetailService.deleteStadiumDetailByIds(ids));
    }
}
